import axios from "axios";
import RequestHooks from "@/request/RequestHooks";

let baseURL: any = undefined;
if (process.env.NODE_ENV === 'production') {
  baseURL = '/icp'
}
if (process.env.NODE_ENV === 'development') {
  baseURL = '/icp'
}

const service = {
  instance: axios.create({
    baseURL,
    timeout: 1000,
  }),
  install(app: any): void {
    app.config.globalProperties.$request = this.instance
  },
};

RequestHooks.forEach(h => h.hook(service.instance));

export {
  service,
};
export default service;
